from selenium import webdriver
import time
from selenium.webdriver.common.by import By

class Use_Chrome:
    #初始化对象.初始化浏览器
    def __init__(self):
        self.driver=webdriver.Chrome()
        # 打开360首页
        self.driver.get('https://www.so.com')

    def search_360(self):
        #定位搜索框,输入内容
        self.driver.find_element(By.ID,'input').send_keys('python自动化测试')
        #定位搜素按钮,点击
        self.driver.find_element(By.ID,'search-button').click()
        # 搜索后让网页多加载5s
        time.sleep(5)
        #获取页面标题并打印
        print(self.driver.title)
        if 'python' in self.driver.title:
            print('找到了')
        else:
            print('没找到')

    def close(self,second):
        time.sleep(second)
        self.driver.quit()

a =Use_Chrome()
a.search_360()
a.close(3)


















